package com.csh.szhm.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.csh.szhm.SzhmApplication;
import com.csh.szhm.activity.MyBaseActivity;

public class AppConfig {
	public static int getScreenWidth() {
		return SzhmApplication.getInstance().getResources().getDisplayMetrics().widthPixels;

	}

	public static int getScreenHeight() {
		return SzhmApplication.getInstance().getResources().getDisplayMetrics().heightPixels;

	}

	public static float getScreenDensityDpi() {
		return SzhmApplication.getInstance().getResources().getDisplayMetrics().density;

	}

	public static void callPhone(String phone, Context c) {
		Intent intent = new Intent(Intent.ACTION_DIAL,
				Uri.parse("tel:" + phone));
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		((MyBaseActivity) c).startActivity(intent);
	}

	public static String urlEncode(String temp) {
		String key = "";
		try {
			key = URLEncoder.encode(temp, "UTF-8");
			key = URLEncoder.encode(key, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return key;
	}

	public static String doubleTwoNum(double d) {
		DecimalFormat df = new DecimalFormat("#.0");
		return df.format(d / 1000);
	}
}
